import { DailyAwardList } from "./DailyAwardList";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Language } from "../../../../../extend/language/Language";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { DailyItemRenderer } from "./DailyItemRenderer";
import { PageTool } from "../../../../common/global/PageTool";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { DailyInfo } from "../../../model/DailyInfo";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { CopyConfig } from "../../../resource/CopyConfig";
import { Cache } from "../../../cache/Cache";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
type int = number;
//class CopyAwardList
    
    export  class CopyAwardList extends DailyAwardList
    {
        constructor(arg1: int, arg2: int)
        {
            super(arg1, arg2);
            return;
        }

        /* internal  */onImgBgLoadedHandler(arg1: ImageInfo): void
        {
            if (arg1 && arg1.bitmapData) 
            {
                this._imgBg.bitmapData = arg1.bitmapData;
            }
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            return;
        }

        protected /* override */ createDailyInfo(): void
        {
            this._imgBg = new Object /* flash.display.Bitmap */();
            addChild(this._imgBg);
            super.createDailyInfo();
            this._imgBg.x = 1;
            this._imgBg.y = 2;
            this._delegateTxt = new Object /* flash.text.TextField */();
            this._delegateTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._delegateTxt.width = width - 10;
            this._delegateTxt.height = 30;
            this._delegateTxt.mouseEnabled = false;
            this._delegateTxt.x = 5;
            this._delegateTxt.filters = [FilterConst.nameGlowFilter];
            return;
        }

        protected /* override */ createRewardList(): void
        {
            super.createRewardList();
            removeChild(_line);
            _titleBg2.y = 224;
            _titleTxt2.y = _titleBg2.y + 4;
            _titleTxt2.text = Language.getString(20958);
            return;
        }

        protected /* override */ createRewardStar(): void
        {
            super.createRewardStar();
            _rewardItem1.y = 165;
            _rewardItem2.y = _rewardItem1.y + 18;
            _rewardItem3.y = _rewardItem2.y + 18;
            return;
        }

        protected /* override */ createRwardList(): void
        {
            var loc1=0;
            var loc3=null;
            loc1 = 0;
            var loc2=11;
            while (loc1 <= loc2) 
            {
                loc3 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                loc3.x = 15 + Math.floor(loc1 % 4) * 46;
                loc3.y = 262 + Math.floor(loc1 / 4) * 38;
                addChild(loc3);
                ++loc1;
            }
            _itemList = new GTileList();
            _itemList.rowHeight = 36;
            _itemList.columnWidth = 36;
            _itemList.horizontalGap = 10;
            _itemList.verticalGap = 2;
            _itemList.columnCount = 4;
            _itemList.rowCount = 3;
            _itemList.width = 175;
            _itemList.height = 120;
            _itemList.horizontalScrollPolicy = ScrollPolicy.OFF;
            _itemList.verticalScrollPolicy = ScrollPolicy.OFF;
            _itemList.setStyle("skin", new Object /* flash.display.Bitmap */());
            _itemList.setStyle("cellRenderer", DailyItemRenderer);
            _itemList.x = 18;
            _itemList.y = 265;
            addChild(_itemList);
            _page = new PageTool([], 12);
            _pageBar = new PageSelecter();
            _pageBar.mode = PageSelecter.SingleMode;
            _pageBar.x = 65;
            _pageBar.y = 378;
            addChild(_pageBar);
            _pageBar.addEventListener(flash.events.Event.CHANGE, onCurPageChangeHandler);
            return;
        }

        public /* override */ updateData(arg1: DailyInfo): void
        {
            var loc3=null;
            super.updateData(arg1);
            _titleTxt1.text = arg1.name;
            _titleTxt2.text = Language.getString(20958);
            LoaderManager.instance.load(arg1.url, this.onImgBgLoadedHandler);
            var loc1=arg1.copyId;
            var loc2=CopyConfig.instance.getInfoByCode(loc1);
            if (loc2) 
            {
                if (loc3 = Cache.instance.delegateTask.getCopyDelegateConfig(loc2)) 
                {
                    if (loc2.copyType == ECopyType._ECopy60Defense || loc2.copyType == ECopyType._ECopyDefense) 
                    {
                        this._delegateTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(69718, loc3["level"], loc3["passTimes"]), GlobalStyle.color1);
                    }
                    else 
                    {
                        this._delegateTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(69626, loc3["level"], loc3["capability"]), GlobalStyle.color1);
                    }
                    if (!contains(this._delegateTxt)) 
                    {
                        addChild(this._delegateTxt);
                    }
                    this._delegateTxt.y = _infoTxt.y + _infoTxt.textHeight + 10;
                }
                else if (contains(this._delegateTxt)) 
                {
                    removeChild(this._delegateTxt);
                }
            }
            else if (contains(this._delegateTxt)) 
            {
                removeChild(this._delegateTxt);
            }
            return;
        }

        protected /* var */_imgBg: Object /* flash.display.Bitmap */;

        protected /* var */_delegateTxt: Object /* flash.text.TextField */;
    }
